from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
browser = webdriver.Chrome(chrome_options=options, executable_path="chromedriver.exe")
# 保持最大窗口
browser.maximize_window()
browser.get('file:///K:/outlook邮件爬取/res_html.html')

xp = browser.find_elements_by_xpath('//div[3]/div/table/tbody/tr/td/table/tbody/tr/td[1]/table/tbody/'
                                    'tr[2]/td/p/b/span/a')[0].get_attribute('href')
print(xp)
xp = xp.replace('&', '&amp;')
# print(xp)
with open('res_html.html', 'r', encoding='utf-8') as f:
    data = f.read()
    data = data.replace(xp, 'https://ar.intra.nsfocus.com/pages/viewpage.action?pageId=24885694')

with open('res_html.html', 'w', encoding='utf-8') as f:
    f.write(data)
print('ok')

browser.quit()